<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <script th:src="@{/common/js/jquery.min.js}" type="text/javascript"></script>
    <script th:src="@{/common/layui/layui.js}" type="text/javascript"></script>
    <script th:src="@{/common/layui/layui.all.js}" type="text/javascript"></script>
    <script th:src="@{/common/js/base.js}" type="text/javascript"></script>
    <script th:src="@{/common/js/userServer.js}" type="text/javascript"></script>
    <link rel="stylesheet" th:href="@{/common/layui/css/layui.css}">
    <style>
        .stype {
            margin-top: 4vh;
            margin-left: 9.5vw;
            width: 80vw;
            height: 80vh;
            border: #6c7994 1px solid;
            border-radius: 10px;
        }

        .layui-input {
            width: 60%;
        }
    </style>
</head>
<body>
<div class="stype">
    <h2 style="text-align: center;margin-top: 2vh">拍品类别</h2>
    <div class="layui-form" style="margin-top: 3vh">
        <div class="layui-form-item">
            <label class="layui-form-label">商品类别</label>
            <div class="layui-input-block">
                <input id="tname" type="text" name="type" required lay-verify="required" placeholder="请输入类别"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </div>
</div>
<script>
    $("#formDemo").click(function () {
        var taname = $("#tname").val();
        if(!taname){
            layer.alert("请输入需要添加的商品类别")
            return;
        }
        var param = {};
        param.tname =taname;
        Base.requestServer("addStype", param, successFun, true)
    });

    function successFun(data) {
        if(data==Base.result_suc){
            layer.alert("添加成功");
            $("#tname").val("");
        }else if(data==0){
            layer.alert("添加类别已存在，请删除后在重新添加");
            $("#tname").val("");
        }else {
            layer.alert("添加失败，请稍后再试");
        }
    }
</script>
</body>
</html>